using System;
using Expect.Core;

namespace Expect.Documentation.Fixtures
{
    [FixtureHint("I don't remember my |*| table for |*|")]
    [FixtureHint("I forget my |*| table for |*|")]
    public class IForgetMyTableFor : Expect.Core.Fixtures.ColumnFixture
    {
        private Func<int, int> _inneroperator;
        
        private string _operatortype;

        private int _operationBase;

        public int Value { get; set;}

        public IForgetMyTableFor(string operatortype, int operationBase)
        {
            _operatortype = operatortype;
            _operationBase = operationBase;

            switch (_operatortype)
            {
                case "addition":
                    _inneroperator = (val) => val + operationBase;
                    break;
                case "multiplication":
                    _inneroperator = (val) => val * operationBase;
                    break;
                case "division":
                    _inneroperator = (val) => val / operationBase;
                    break;
                default:
                    throw new ArgumentException("The operator type " + _operatortype + " is invalid");
            }
        }

        public int Result()
        {
            return _inneroperator(Value);
        }
    }
}
